package com.zhilianbao.leyaogo.utils;

/**
 * ClassName: FloatingViewHelper <br>
 * Description: FloatingView 帮助类<br>
 * Author: Cyarie <br>
 * Created: 2016/11/8 16:06 <br>
 * Update Time：<br>
 * Update Description：<br>
 */
public class FloatingViewHelper {

//    private Floating mFloating;
//    private Activity mActivity;
//
//    public FloatingViewHelper(Activity activity) {
//        mFloating = new Floating(activity);
//        mActivity = activity;
//
//    }
//
//
//    public void addToShoppingCart(ImageView startView, View endView) {
//        ImageView imageView = new ImageView(mActivity);
//        imageView.setLayoutParams(new FrameLayout.LayoutParams(startView.getWidth(), startView.getHeight()));
//        imageView.setImageDrawable(startView.getDrawable());
//        FloatingElement floatingElement = new FloatingBuilder()
//                .anchorView(startView)
//                .targetView(imageView)
//                .floatingTransition(new ShoppingFloating(startView, endView))
//                .build();
//        mFloating.startFloating(floatingElement);
//    }
//
//    public class ShoppingFloating extends BaseFloatingPathTransition {
//
//        private View endView;
//        private View startView;
//        private int startLoc[] = new int[2];
//        private int endLoc[] = new int[2];
//
//        public ShoppingFloating(View startView, View endView) {
//            this.startView = startView;
//            this.endView = endView;
//            this.startView.getLocationOnScreen(startLoc);
//            this.endView.getLocationOnScreen(endLoc);
//        }
//
//        @Override
//        public FloatingPath getFloatingPath() {
//            Path path = new Path();
//            path.moveTo(0, 0);
//            path.quadTo(endLoc[0] / 2, 0, endLoc[0], endLoc[1]);
//            return FloatingPath.create(path, false);
//        }
//
//        @Override
//        public void applyFloating(final YumFloating yumFloating) {
//
//            ValueAnimator translateAnimator = ObjectAnimator.ofFloat(getStartPathPosition(), getEndPathPosition());
//            translateAnimator.addUpdateListener(animation -> {
//                float value = (float) animation.getAnimatedValue();
//                PathPosition floatingPosition = getFloatingPosition(value);
//                yumFloating.setTranslationX(floatingPosition.x);
//                yumFloating.setTranslationY(floatingPosition.y);
//            });
//            translateAnimator.addListener(new AnimatorListenerAdapter() {
//                @Override
//                public void onAnimationEnd(Animator animation) {
//                    super.onAnimationEnd(animation);
//                    yumFloating.setTranslationX(0);
//                    yumFloating.setTranslationY(0);
//                    yumFloating.setAlpha(0f);
//                    yumFloating.clear();
//                }
//            });
//
//            //
//            //            SpringHelper.createWidthBouncinessAndSpeed(0.0f, 1.0f, 14, 15)
//            //                    .reboundListener(new SimpleReboundListener() {
//            //                        @Override
//            //                        public void onReboundUpdate(double currentValue) {
//            //                            yumFloating.setScaleX((float) currentValue);
//            //                            yumFloating.setScaleY((float) currentValue);
//            //                        }
//            //                    }).start(yumFloating);
//
//            translateAnimator.setDuration(1000);
//            translateAnimator.start();
//        }
//    }
}
